<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<link rel="stylesheet"
	href="http://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css"
	type="text/css" />
<script type="text/javascript"
	src="https://code.jquery.com/jquery-1.11.3.js"></script>
<script type="text/javascript"
	src="http://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		$('#example').dataTable();
	});

	function appSettingChange(clientid) {

		var appSetting = $("#appSettingSelect" + clientid).val();
		var clientId = clientid;

		$.ajax({
			url : "updateAndroidEx?appSetting=" + appSetting + "&"
					+ "clientId=" + clientid,
			type : "POST",
			dataType : "json",
			success : function(jdata, stat) {
				alert("成功");
			}
		});
	}

	function switchChange(clientid) {

		var switch_ = $("#switchSelect" + clientid).val();
		var clientId = clientid;

		$.ajax({
			url : "updateAndroidEx?switch_=" + switch_ + "&" + "clientId="
					+ clientid,
			type : "POST",
			dataType : "json",
			success : function(jdata, stat) {
				alert("成功");
			}
		});
	}
</script>

</head>
<body>

	<table id="example" class="display" cellspacing="0" width="100%">
		<thead>
			<tr>
				<th>编号</th>
				<th>mac地址</th>
				<th>手机号码</th>
				<th>手机型号</th>
				<th>设备id</th>
				<th>版本号</th>
				<th>html包下载地址</th>
				<th>app环境</th>
				<th>是否启用</th>
			</tr>
		</thead>

		<tbody>

			<c:forEach items="${androidList}" var="node">

				<tr>

					<td>${node.setId}</td>
					<td>${node.macAdd}</td>
					<td>${node.telPhone}</td>
					<td>${node.phoneModle}</td>
					<td>${node.clientId}</td>
					<td>${node.appVersion}</td>
					<td>
						<form name="Form2" action="fileUpload?clientId=${node.clientId}"
							method="post" enctype="multipart/form-data">
							${node.mPagAdd}
							<input type="file" name="file"> <input type="submit"
								value="上传" />
						</form>
					
					</td>
					<td><select id="appSettingSelect${node.clientId}"
						name="appSetting" onchange="appSettingChange('${node.clientId}')">
							<option value="1" ${node.appSetting==1?'selected':''}>生产</option>
							<option value="2" ${node.appSetting==2?'selected':''}>预部署</option>
							<option value="3" ${node.appSetting==3?'selected':''}>测试</option>
					</select></td>

					<td><select id="switchSelect${node.clientId}" name="switch_"
						onchange="switchChange('${node.clientId}')">
							<option value="1" ${node.switch_==1?'selected':''}>启用</option>
							<option value="-1" ${node.switch_==-1?'selected':''}>关闭</option>
					</select></td>
				</tr>
			</c:forEach>


		</tbody>
	</table>
</body>

</html>